package com.pipodi.itasamobile.model;


import com.pipodi.itasamobile.R;
import com.pipodi.itasamobile.model.interfaces.NewsInterface;

import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public class News implements NewsInterface {

	private int ID;
	private String title;
	private String episode;
	private String release_date;
	private Bitmap image;

	public News(int id, String title, String episode, String release,
			Bitmap image) {
		this.title = title;
		this.episode = episode;
		this.release_date = release;
		this.image = image;
		this.ID = id;
	}

	@Override
	public View getView(LayoutInflater inflater, View convertView) {
		if (convertView == null) {
			convertView = (View) inflater.inflate(R.layout.item_layout, null);
		}

		TextView textTitle = (TextView) convertView
				.findViewById(R.id.title_viewer);
		textTitle.setText(title);
		TextView textEpisode = (TextView) convertView
				.findViewById(R.id.episode_viewer);
		textEpisode.setText(episode);
		TextView textRelease = (TextView) convertView
				.findViewById(R.id.release_date_viewer);
		textRelease.setText(release_date);
		ImageView photoView = (ImageView) convertView
				.findViewById(R.id.photo_viewer);
		photoView.setImageBitmap(this.image);
		return convertView;
	}

	@Override
	public String getTitle() {
		return this.title;
	}

	@Override
	public String getEpisode() {
		return this.episode;
	}

	@Override
	public String getReleaseDate() {
		return this.release_date;
	}

	@Override
	public Bitmap getPhoto() {
		return this.image;
	}

	@Override
	public String toString() {
		return "[ID: " + this.ID + " ; Title: " + this.title + " ; Episode: "
				+ this.episode + " ; Release: " + this.release_date;
	}

	@Override
	public int getID() {
		return this.ID;
	}

}
